<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<h2 id="time"></h2>

<body>
  <script>
    function counter() {
      var date = new Date();
      var year = date.getFullYear();
      var date2 = new Date(year, 12, 31, 23, 59, 59);
      var time = (date2 - date) / 1000;
      var day = Math.floor(time / (24 * 60 * 60))
      var hour = Math.floor(time % (24 * 60 * 60) / (60 * 60))
      var minute = Math.floor(time % (24 * 60 * 60) % (60 * 60) / 60);
      var second = Math.floor(time % (24 * 60 * 60) % (60 * 60) % 60);
      var str = year + "年还剩" + day + "天" + hour + "时" + minute + "分" + second + "秒";
      document.getElementById("time").innerText = str;
    }
    window.setInterval("counter()", 1000);
    //--------------------------------------------------------
    //--------------------------------------------------------
    //--------------------------------------------------------
    //--------------------------------------------------------
    /*
    let validator= {
      set: function(obj,prop,value) {
        if(prop === 'age') {
          if(!Number.isInteger(value)) {
            throw new TypeError('The age is not an Integer');
          }
          if(value > 200) {
            throw new RangeError('The age seems invalid')
          }
        }
        if(prop === 'name') {
          if(Number.isInteger(value)) {
            throw new TypeError('Name is not an Integer');
          }
        }
        //对于满足条件的age属性以及其他属性，直接保存
        obj[prop] = value;
        return true;
      }
    };
    let person = new Proxy({},validator)
    person.age = 100;
    //--------------------------------------
    const obj = {};
    Object.defineProperty(obj,'foo',{
      value: 'bz',
      writable: false
    });

    const handler = {
      set: function(obj,prop,value,receiver) {
        obj[prop] = 'baz';
        return true;
      }
    };

    const proxy = new Proxy(obj,handler);
    proxy.foo = 'baz';
    //--------------------------------------
    var proto = {};
    var p = new Proxy({},{
      getPrototypeOf(target) {
        return proto;
      }
    })*/
    // let student = {
    //   name: 'aaa',
    //   age: 18,
    //   sex: '',
    //   height: 170,
    //   weight: null,
    //   id: undefined,
    //   address: '',
    // };
    // for(let key in student) {
    //   if(student[key]) {
    //     console.log(student[key]);
    //   } else {
    //     // console.log('无值');
    //     delete(student[key])
    //   }
    // }

    // let keys = Object.keys(student);
    // keys.forEach(item=>{
    //   console.log(student[item]);
    //   if(student[item]) {
    //     console.log(item);
    //   } else {
    //     console.log('无值');
    //     delete(student[item])
    //   }
    // })
    // console.log(student);
  </script>
</body>

</html>